<template>
  <basic-container>
    <avue-crud :option="option"
               :table-loading="loading"
               :data="data"
               ref="crud"
               v-model="form"
               :permission="permissionList"
               :page.sync="page"
               @search-change="searchChange"
               @search-reset="searchReset"
               @current-change="currentChange"
               @size-change="sizeChange"
               @refresh-change="refreshChange"
               @on-load="onLoad">
      <template slot="menu" slot-scope="scope">
        <el-button type="text"  icon="el-icon-tickets" size="small" @click="guideShowStatus(scope.row)">详情</el-button>
        <el-button type="text"  icon="el-icon-tickets" size="small" @click="guideShowStatus1(scope.row)">对比</el-button>
      </template>

      <template slot-scope="scope"
                slot="anticipateday">
        {{scope.row.anticipateday+'个工作日'}}
      </template>
    </avue-crud>
    <!-- 事项历史版本   -->
    <el-drawer center="true"
               size="calc(100% - 240px)"
               title="办事指南"
               append-to-body
               :visible.sync="enentHistoryShow">
      <service_guide_history :serviceItemOneHistory="eventHistory"
                             v-if="enentHistoryShow">
      </service_guide_history>
    </el-drawer>
    <el-drawer center="true"
               size="calc(100% - 240px)"
               append-to-body
               :visible.sync="enentHistoryShow1">
      <comparison :serviceItemOneHistory="eventHistory1"
                             v-if="enentHistoryShow1">
      </comparison>
    </el-drawer>
  </basic-container>
</template>

<script>
    import {mapGetters} from "vuex";
    import {getDetailByTaskCodeAndItemId} from "@/api/acceptance/taskgeneralbasicHistory";
    import service_guide_history from "@/views/eventManagement/service_guide_history";
    import comparison from "@/views/eventManagement/comparison";
    export default {
        name: "eventInquiryHistory",
      components:{service_guide_history,comparison},
      data(){
          return{
            enentHistoryShow:false,
            eventHistory:{},
            enentHistoryShow1:false,
            eventHistory1:{},
            loading: false,
            form: {},
            page: {
              currentPage: 1,
              pageSize: 10,
              total: 0
            },
            data: [],
            query: {},
            option:{
              lazy:true,
              tip: false,
              searchShow: true,
              searchMenuSpan: 24,
              searchMenuPosition:'right',
              border: true,
              index: true,
              indexLabel: "序号",
              viewBtn: false,
              selection: false,
              dialogClickModal: false,
              simplePage: true,
              editBtn: false,
              searchLabelWidth:150,
              addBtn: false,
              delBtn: false,
              dialogType: 'drawer',
              refreshBtn: false,
              columnBtn: false,
              searchShowBtn: false,
              column: [
                {
                  label: "事项名称",
                  prop: "taskname",
                  rules: [{
                    required: true,
                    message: "请输入事项名称",
                    trigger: "blur"
                  }],
                  overHidden: true,
                },
                {
                  label: "事项编码",
                  prop: "taskCode",
                  rules: [{
                    required: true,
                    message: "请输入事项编码",
                    trigger: "blur"
                  }],
                  search: false,
                  align: "center",
                  hide: true,
                },
                // {
                //     label: "事项/业务项编码",
                //     prop: "taskCodeOrTaskHandleItem",
                //     rules: [{
                //         required: true,
                //         message: "请输入事项编码",
                //         trigger: "blur"
                //     }],
                //     search: true,
                //     align: "center",
                //     display: false,
                // },
                {
                  label: "基本编码:见C 0109.1-2018的第4章",
                  prop: "catalogCode",
                  rules: [{
                    required: true,
                    message: "请输入基本编码:见C 0109.1-2018的第4章",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "地方基本编码:地方基本目录基本编码",
                  prop: "localCatalogCode",
                  rules: [{
                    required: true,
                    message: "请输入地方基本编码:地方基本目录基本编码",
                    trigger: "blur"
                  }],
                  hide: true,
                },
                {
                  label: "事项类型",
                  prop: "tasktype",
                  type: "select",
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=task_type",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请输入事项类型",
                    trigger: "blur"
                  }],
                  width: 100,
                  align: "center",
                },
                {
                  label: "设定依据",
                  prop: "byLaw",
                  rules: [{
                    required: true,
                    message: "请输入设定依据",
                    trigger: "blur"
                  }],
                  type: "textarea",
                  span: 24,
                  hide: true
                },
                {
                  label: "权力来源",
                  prop: "powerSource",
                  type: "select",
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=power_source",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: false,
                    message: "请输入权力来源",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "行使层级",
                  prop: "useLevel",
                  type: "select",
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=use_level",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请输入行使层级",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "地方实施编码:地方实施清单基本编码",
                  prop: "localTaskCode",
                  rules: [{
                    required: true,
                    message: "请输入地方实施编码:地方实施清单基本编码",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "业务办理项编码:有业务办理项，该项必填，见C 0109.1-2018的第6章",
                  prop: "taskHandleItem",
                  rules: [{
                    required: true,
                    message: "请输入业务办理项编码:有业务办理项，该项必填，见C 0109.1-2018的第6章",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "事项状态",
                  prop: "taskState",
                  type: "select",
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=task_state",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请输入事项状态",
                    trigger: "blur"
                  }],
                  align: "center",
                  width: 100,
                  hide: true,
                },
                {
                  label: "事项版本",
                  prop: "taskVersion",
                  rules: [{
                    required: true,
                    message: "请输入事项版本",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "实施主体",
                  prop: "deptname",
                  rules: [{
                    required: true,
                    message: "请输入实施主体",
                    trigger: "blur"
                  }],
                  align: "left",
                },
                {
                  label: "实施主体性质:代码集为“实施主体性质”",
                  prop: "deptType",
                  rules: [{
                    required: true,
                    message: "请输入实施主体性质:代码集为“实施主体性质”",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "实施主体编码:统一社会信用代码",
                  prop: "deptCode",
                  rules: [{
                    required: true,
                    message: "请输入实施主体编码:统一社会信用代码",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "委托部门:当实施主体性质为受委托组织时，该项必填",
                  prop: "entrustName",
                  rules: [{
                    required: true,
                    message: "请输入委托部门:当实施主体性质为受委托组织时，该项必填",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "法定办结时限",
                  prop: "anticipateday",
                  slot: true,
                  rules: [{
                    required: true,
                    message: "请输入法定办结时限",
                    trigger: "blur"
                  }],
                  width: 120,
                  align: "center",
                },
                {
                  label: "法定办结时限单位:代码集为“时限单位”",
                  prop: "anticipateType",
                  type: "select",
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=time_limit_type",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请输入法定办结时限单位:代码集为“时限单位”",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "法定办结时限说明",
                  prop: "anticipateExplain",
                  rules: [{
                    required: true,
                    message: "请输入法定办结时限说明",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "承诺办结时限:对外承诺办结时限，无承诺办结期限的应与法定办结期限一致",
                  prop: "promiseDay",
                  rules: [{
                    required: true,
                    message: "请输入承诺办结时限:对外承诺办结时限，无承诺办结期限的应与法定办结期限一致",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "承诺办结时限单位:代码集为“时限单位”",
                  prop: "promiseType",
                  type: "select",
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=time_limit_type",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请输入承诺办结时限单位:代码集为“时限单位”",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "承诺办结时限说明",
                  prop: "promiseExplain",
                  rules: [{
                    required: true,
                    message: "请输入承诺办结时限说明",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "受理条件:法规和文件列明的具体条件",
                  prop: "acceptCondition",
                  rules: [{
                    required: true,
                    message: "请输入受理条件:法规和文件列明的具体条件",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "办理流程:描述所涉及的法定程序和环节要求（如申请、受理、审查、决定、制证发证等），并附以相应的文字说明。办理流程可以是文本说明、流程图或文本说明+流程图，具体标准详见办理流程编制说",
                  prop: "handleFlow",
                  rules: [{
                    required: true,
                    message: "请输入办理流程:描述所涉及的法定程序和环节要求（如申请、受理、审查、决定、制证发证等），并附以相应的文字说明。办理流程可以是文本说明、流程图或文本说明+流程图，具体标准详见办理流程编制说",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "是否收费",
                  prop: "isfee",
                  type: "radio",
                  dicData: [
                    {
                      label: "是",
                      value: "1"
                    },
                    {
                      label: "否",
                      value: "0"
                    }
                  ],
                  rules: [{
                    required: true,
                    message: "请输入是否收费",
                    trigger: "blur"
                  }],
                  width: 100,
                  align: "center",
                },
                {
                  label: "收费依据:在此处填写或在收费信息表中填写。若本要素有值，将忽略收费项目信息表中的收费依据内容",
                  prop: "feeBasis",
                  rules: [{
                    required: false,
                    message: "请输入收费依据:在此处填写或在收费信息表中填写。若本要素有值，将忽略收费项目信息表中的收费依据内容",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "服务对象",
                  prop: "serverType",
                  type: "select",
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=ApplyerType",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请输入服务对象",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "办件类型",
                  prop: "projecttype",
                  type: "select",
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=offciceType",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请输入办件类型",
                    trigger: "blur"
                  }],
                  align: "center",
                  width: 100,
                },
                {
                  label: "办理形式",
                  prop: "handleType",
                  type: "select",
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=handleType",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: false,
                    message: "请输入办理形式",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "到办事现场次数:",
                  prop: "limitSceneNum",
                  rules: [{
                    required: true,
                    message: "请输入到办事现场次数:",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "特别程序:无特别程序，填报“无”",
                  prop: "specialProcedure",
                  rules: [{
                    required: true,
                    message: "请输入特别程序:无特别程序，填报“无”",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "移动端是否对接单点登录:代码集为“是否”",
                  prop: "appisSingleLogin",
                  rules: [{
                    required: true,
                    message: "请输入移动端是否对接单点登录:代码集为“是否”",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "移动端办理地址:“移动端是否对接单点登录”为“是”时，则该要素必填，填写各部门、各省业务系统移动端办理事项的中间处理页面地址",
                  prop: "mobileTerminalUrl",
                  rules: [{
                    required: true,
                    message: "请输入移动端办理地址:“移动端是否对接单点登录”为“是”时，则该要素必填，填写各部门、各省业务系统移动端办理事项的中间处理页面地址",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "计算机端是否对接单点登录:是否对接了国家政务服务平台单点登录。代码集为“是否”",
                  prop: "isSingleLogin",
                  rules: [{
                    required: true,
                    message: "请输入计算机端是否对接单点登录:是否对接了国家政务服务平台单点登录。代码集为“是否”",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "计算机端在线办理跳转地址:“计算机端是否对接单点登录”为“是”时，则该要素必填，填写各部门、各省业务系统计算机端办理事项的中间处理页面地址",
                  prop: "linkAddr",
                  rules: [{
                    required: true,
                    message: "请输入计算机端在线办理跳转地址:“计算机端是否对接单点登录”为“是”时，则该要素必填，填写各部门、各省业务系统计算机端办理事项的中间处理页面地址",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "办理地点:具体承办单位所在地点",
                  prop: "transactAddr",
                  rules: [{
                    required: true,
                    message: "请输入办理地点:具体承办单位所在地点",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "办理时间",
                  prop: "transactTime",
                  rules: [{
                    required: true,
                    message: "请输入办理时间",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "咨询方式:包括电话、信件、邮件等多种咨询方式",
                  prop: "linkWay",
                  rules: [{
                    required: true,
                    message: "请输入咨询方式:包括电话、信件、邮件等多种咨询方式",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "监督投诉方式:包括电话、信件、邮件等多种方式",
                  prop: "superviseWay",
                  rules: [{
                    required: true,
                    message: "请输入监督投诉方式:包括电话、信件、邮件等多种方式",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "计划生效日期",
                  prop: "planEffectiveDate",
                  rules: [{
                    required: true,
                    message: "请输入计划生效日期",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "计划取消日期",
                  prop: "planCancelDate",
                  rules: [{
                    required: true,
                    message: "请输入计划取消日期",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "同步类型:I-插入 U-更新 D-删除",
                  prop: "cdOperation",
                  rules: [{
                    required: true,
                    message: "请输入同步类型:I-插入 U-更新 D-删除",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "同步时间:",
                  prop: "cdTime",
                  rules: [{
                    required: true,
                    message: "请输入同步时间:",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "批次号:每次交换应唯一，用于数据对账",
                  prop: "cdBatch",
                  rules: [{
                    required: true,
                    message: "请输入批次号:每次交换应唯一，用于数据对账",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "数据来源:数据来源由三位数字组成。其中，第1位填写：0或者1，0代表中央业务指导（实施）部门，1代表地方。当第1位填写0时，第2、3位填写“中央业务指导（实施）部门代码”代码集中对应的代码；当第1位填写1时，第2、3位填写 “行政区划代码”代码集中对应的代码",
                  prop: "dataSource",
                  rules: [{
                    required: true,
                    message: "请输入数据来源:数据来源由三位数字组成。其中，第1位填写：0或者1，0代表中央业务指导（实施）部门，1代表地方。当第1位填写0时，第2、3位填写“中央业务指导（实施）部门代码”代码集中对应的代码；当第1位填写1时，第2、3位填写 “行政区划代码”代码集中对应的代码",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "部门id",
                  prop: "deptId",
                  rules: [{
                    required: true,
                    message: "请输入部门id",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "区划编码",
                  prop: "areaCode",
                  rules: [{
                    required: true,
                    message: "请输入区划编码",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "目录清单唯一id",
                  prop: "directoryGuid",
                  rules: [{
                    required: true,
                    message: "请输入目录清单唯一id",
                    trigger: "blur"
                  }],
                  hide: true
                },
                {
                  label: "版本同步时间",
                  prop: "syncDate",
                  width: 160,
                  align: "center"
                },
                {
                  label: "版本号",
                  prop: "taskversion",
                  align: "center",
                  width: 80,
                  search: true
                }
              ]
            }
          }
      },
      props:{
        serviceHistory:{}
      },
      computed: {
        ...mapGetters(["permission"]),
        permissionList() {
          return {
            viewBtn: this.vaildData(this.permission.register_view, false),
          };
        },
      },
      methods:{
        guideShowStatus(row){
          this.eventHistory = row;
          this.enentHistoryShow = true
        },
        guideShowStatus1(row){
          this.eventHistory1.row = row;
          this.enentHistoryShow1 = true
        },
        searchReset() {
          this.query = {};
          this.onLoad(this.page);
        },
        searchChange(params, done) {
          this.query = params;
          this.page.currentPage = 1;
          this.onLoad(this.page, params);
          done();
        },
        currentChange(currentPage) {
          this.page.currentPage = currentPage;
        },
        sizeChange(pageSize) {
          this.page.pageSize = pageSize;
        },
        refreshChange() {
          this.onLoad(this.page, this.query);
        },
        onLoad(page, params = {}) {
          this.loading = true;
          const values = {
            ...params,
            tasktype:this.serviceHistory.taskType,
            taskcode:this.serviceHistory.taskCode,
            itemId:this.serviceHistory.itemId
          }
          getDetailByTaskCodeAndItemId(page.currentPage, page.pageSize, Object.assign(values, this.query)).then(res => {
            const data = res.data.data;
            this.page.total = data.total;
            this.data = data.records;
            this.eventHistory1.records=data.records
            this.loading = false;
          });
        },
      }
    }
</script>

<style scoped>
  /deep/.el-drawer__body {
    overflow: auto;
  }
</style>
